package fr.vahren.dotastrat.gui;

import com.trolltech.qt.gui.QHBoxLayout;
import com.trolltech.qt.gui.QLayout;
import com.trolltech.qt.gui.QVBoxLayout;
import com.trolltech.qt.gui.QWidget;

import fr.vahren.dotastrat.model.D2SHeroUnit;

public class D2SHeroInfoWidget extends QWidget {

	private D2SLabel name = new D2SLabel("???", "black", 12);
	private D2SBarWiget health;
	private D2SBarWiget mana;
	private D2SLabel buffs = new D2SLabel("none", "grey", 8);
	private D2SLabel statsLabel = new D2SLabel("###", "orange", 10);

	public D2SHeroInfoWidget(D2SHeroUnit unit) {
		setLayout(new QHBoxLayout());
		layout().addWidget(new D2SHeroPortrait());

		name.setText(unit.getName());
		health = new D2SBarWiget(unit.getStats().getHealth(), unit.getStats()
				.getMaxHealth(), "green");
		mana = new D2SBarWiget(unit.getStats().getMana(), unit.getStats()
				.getMaxMana(), "blue");
		statsLabel.setText("damage : " + unit.getDamage() + " armor : "
				+ unit.getArmor());

		QWidget stats = new QWidget();
		QLayout statsLayout = new QVBoxLayout();
		statsLayout.addWidget(name);
		statsLayout.addWidget(health);
		statsLayout.addWidget(mana);
		statsLayout.addWidget(buffs);
		statsLayout.addWidget(statsLabel);
		stats.setLayout(statsLayout);
		layout().addWidget(stats);
		setFixedHeight(110);
		setStyleSheet("QWidget { border: 2px solid black;} QLabel {border : 0;}");
	}

	public void select() {
		setStyleSheet("QWidget { border: 2px solid yellow;} QLabel {border : 0;}");
	}

}
